package cn.com.zhaish.thinkinjava.nio;

import java.io.IOException;
import java.nio.ByteBuffer;

public class GetData {
	private static final int size = 1024;
	public static void main(String[] args) throws IOException {
		ByteBuffer buff =ByteBuffer.allocate(size);
		int i = 0;
		while (i <buff.limit()) {
			if (buff.get() != 0) {
				System.out.println("nonzero");
			}
		}
		System.out.println("i = " + i);
		buff.rewind();
		buff.asCharBuffer().put("Howdy!");
		char c;
		while ( (c=buff.getChar()) != 0) {
			System.out.println(c+ " ");
		}
		System.out.println("=======");
		buff.rewind();
		buff.asShortBuffer().put((short)471142);
		buff.rewind();
		buff.asIntBuffer().put(9947114);
		System.out.println(buff.getShort());
	}

}
